import Taro, { Component } from '@tarojs/taro'
// import { AtButton } from 'taro-ui'
import { View,Image,Swiper,SwiperItem } from '@tarojs/components'
import './index.less'
import cf from '../../store/modules/cfStore'


class Index extends Component {
  constructor(){
    super()
    this.state = {
      bannerData: [],
      totalUser: 0,
      user: 0,
      // lastInspectionVehicleTime: null
    }
  }
  componentWillMount () { 
    const {fetchHomeData} = cf
    fetchHomeData().then(res => {
      console.log('fec',res)
      const {bannerData,totalUser,usingUser,lastInspectionVehicleTime} = res
      this.setState({
        bannerData: bannerData,
        totalUser: totalUser,
        user: usingUser,
        // lastInspectionVehicleTime: lastInspectionVehicleTime
      })
    })
   }
  componentDidMount () { }
  componentWillUnmount () { }
  componentWillReact () {
    console.log('componentWillReact')
  }
  config = {
    navigationBarTitleText: '易理赔用户端'
  }
  componentDidShow () { }
  componentDidHide () { }
  
  render () {
    const {bannerData,totalUser,user} = this.state
    return (
      <View className='index'>
        <View className='index-banner'>
          <Swiper
            className='index-swiper'
            indicatorDots='true'
            autoplay
            circular
          >
            {bannerData.map((bannerItem,index) => {
              return (
                <SwiperItem key={index}>
                  <Image 
                    src={bannerItem.picture} 
                    mode='widthFix'  
                    onClick={() => Taro.navigateTo({url: bannerItem.link})}
                  />
                </SwiperItem>
              )
            })}
            
          </Swiper>
        </View>
        <View className='index-body'>
          <View className='index-insurance'>
            <Image src='http://39.98.226.123/xcf/ylp/1.png' mode='widthFix' onClick={() => Taro.navigateTo({url: '/pages/insurance/insurance'})} />
          </View>
          <View className='index-box'>
            <View className='box-item'>
              <View className='index-ylp'>
                <Image src='http://39.98.226.123/xcf/ylp/4.png' mode='widthFix' />
              </View>
              <View className='index-qtfw'>
                <Image src='http://39.98.226.123/xcf/ylp/5.png' mode='widthFix' />
              </View>
            </View>
            <View className='box-item'>
              <View className='index-dbyc'>
                <Image src='http://39.98.226.123/xcf/ylp/3.png' mode='widthFix' />
              </View>
              <View className='index-csyg'>
                <Image src='http://39.98.226.123/xcf/ylp/2.png' mode='widthFix' />
              </View>
            </View>
          </View>
        </View>
        <View className='index-foot'>
          目前为止,共有{totalUser}为客户使用“易理赔服务”,今天共有{user}位使用“易理赔服务”的客户
        </View>
      </View>
    )
  }
}

export default Index 
